package com.chen.blue.listener.event;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationContext;
import org.springframework.context.event.ApplicationContextEvent;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.stereotype.Component;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * Created By CLT On 2024/5/16.
 */
@SuppressWarnings("all")
@Slf4j
@Deprecated
public class SystemConnectValid extends ApplicationContextEvent {
    /**
     * Create a new ContextStartedEvent.
     *
     * @param source the {@code ApplicationContext} that the event is raised for
     *               (must not be {@code null})
     */
    public SystemConnectValid(ApplicationContext applicationContext) throws UnknownHostException {
        super(applicationContext);
        ConfigurableEnvironment environment = (ConfigurableEnvironment) applicationContext.getEnvironment();
        System.out.println("");
        log.info("\n--------------------------{}启动成功----------------------------\n" +
                        "\nAccess Address:http://{}:{}\n" +
                        "\n-------------------------------------------------------------------",
                environment.getProperty("spring.application.name"),
                InetAddress.getLocalHost().getHostAddress(),
                environment.getProperty("server.port"));
    }
}
